<!-- 章列表 组件 -->

<template>
	<view class="live-item">
		<!-- 直播内容 -->
		<view class="item-top">
			<u-image
				width="152rpx" 
				height="140rpx"
				:src="detail.img"
			/>
			<view class="title-box">
				<view class="title">{{detail.title}}</view>
				<view style="display: flex;">
					<u-icon 
						name="clock"
						size="18"
					/>
					<text class="time">{{detail.start_time}}</text>
				</view>
			</view>
		</view>
		<!-- 直播按钮 -->
		<view style="margin-top: 40rpx;">
			<u-button
				plain
				type="primary"
				shape="circle"
				:customStyle="{customBtnStyle}"
				@click="onClickBtn(detail.live_status)"
			>
				{{(detail.is_register == 2 && detail.live_status == 0) ? liveStatusMaper[1] : liveStatusMaper[detail.live_status]  }}
			</u-button>
		</view>
	</view>
</template>


<script>
	
import request from '@/pagesB/common/js/request/userInfo.js';

	/**
	 * @description 直播列表项组件 getLiveUrl
	 */
	export default {
		name: 'live-item',
		props: {
			// 直播列表项数据
			detail: {
				type: Object,
				default() {
					return {}
				}
			}
		},
		
		// 页面数据
		data() {
			return {
				customBtnStyle: {
					width: '560rpx',
					height: '60rpx',
					opacity: 0.8
				},
				// 0参会登记 1直播未开始 2正在直播 3直播结束
				liveStatusMaper: {
					0: '参会登记',
					1: '直播未开始',
					2: '正在直播',
					3: '观看回放'
				}
			}
		},

		// 页面事件
		methods: {
			
			/**
			 * @description 按钮点击
			 * @param {Object} state
			 */
			onClickBtn (state) {
				if(this.detail.is_register == 2){
					uni.$focus.pageJump('/pagesB/pages/study/live/details/index',this.detail);
				}else{
					switch(state){
						case 0:
							// 0 - 参会登记
							if (!this.detail.perfect_status) {
								uni.$focus.pageJump('/pagesB/pages/study/live/index',this.detail);
							}
							break;
						case 1:
							// 1 - 直播未开始
							if (!this.detail.perfect_status) {
								uni.$focus.pageJump('/pagesB/pages/study/live/index',this.detail);
							}else{
								uni.$focus.pageJump('/pagesB/pages/study/live/details/index',this.detail);
							}
							break;
						case 2:
							// 2 - 正在直播
							if (!this.detail.perfect_status) {
								uni.$focus.pageJump('/pagesB/pages/study/live/index',this.detail);
							}else{
								uni.$focus.pageJump('/pagesB/pages/study/live/details/index',this.detail);
							}
							break;
						case 3:
							// 3 - 观看回放
							if (!this.detail.perfect_status) {
								uni.$focus.pageJump('/pagesB/pages/study/live/index',this.detail);
							}else{
								uni.$focus.pageJump('/pagesB/pages/study/live/details/index',this.detail);
							}
							break;
						default:
							break;
					}
				}
				
			}
		},
		
	}
</script>


<style lang="less" scoped>
	.live-item{
		width: 710rpx;
		height: 340rpx;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		margin-top: 40rpx;
		padding: 50rpx 42rpx;
		box-sizing: border-box;
		
		.item-top{
			display: flex;
			flex-direction: row;
			
			.title-box{
				height: 140rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				padding: 5rpx 24rpx;
				word-break:break-all;
				word-wrap:break-word;
				
				.title{
					font-size: 32rpx;
					font-weight: bold;
					text-overflow: ellipsis;
					    display: -webkit-box;
					    -webkit-line-clamp: 2;
					    -webkit-box-orient: vertical;
					    height: 88rpx;
					    overflow: hidden;
				}
				.time{
					font-size: 28;
					padding-left: 10rpx;
					color: #7F7F7F;
				}
			}
		}
	}
</style>